Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

fix: sfdx string flags parse #193

Merged
merged 1 commit into from
Nov 21, 2022
Merged

fix: sfdx string flags parse #193

merged 1 commit into from
Nov 21, 2022

Conversation

mshanemc
Copy link
Contributor

@mshanemc mshanemc commented Nov 18, 2022

What does this PR do?

sfdx flags.string was ignoring any parse method on the flags.

This isn't a full fix, given the short shelf life of sfdxCommand--it's only fixing string flag. Most others still ignore their parse method, too.

You can see our usage of parse here (ingnore repos using sfCommand, which doesn't have this problem)...they're all string flag only.

https://github.com/search?q=org%3Asalesforcecli+%22parse%3A%22+path%3A%2F%5Esrc%5C%2F%2F&type=code&l=src%2F

We only caught it on just-nuts | plugin-org https://github.com/salesforcecli/sfdx-cli/actions/runs/3491014374/jobs/5843317166 where the CLI is on a more recent version of sfdxCommand. This would have been caught much earlier if sfdxCommand had external NUTs (sf-plugins-core does!). Also not changing that given the short shelf-life.

What issues does this PR fix or reference?

discovered as part of @W-12084293@

QA notes:

yarn:link this into plugin-org
./bin/dev force:org:open -u hub -p foo/bar/baz -r --json (without this fix, the url will not be escaped)

@mshanemc mshanemc requested a review from iowillhoit November 18, 2022 20:27
@@ -221,7 +221,7 @@ function buildOption<T>(
}

function buildString(options: flags.String): flags.Discriminated<flags.String> {
return option('string', options, (val: string) => Promise.resolve(val));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this version was always setting parse to a no-op

@@ -221,7 +221,7 @@ function buildOption<T>(
}

function buildString(options: flags.String): flags.Discriminated<flags.String> {
return option('string', options, (val: string) => Promise.resolve(val));
return option('string', options, options.parse ?? ((val: string) => Promise.resolve(val)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parse function is on the options object, so bring that out

@iowillhoit iowillhoit merged commit fc19c47 into main Nov 21, 2022
@iowillhoit iowillhoit deleted the sm/fix-string-parsing branch November 21, 2022 21:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants